package com.wsz.logistic.controller.front;

import com.wsz.logistic.bean.Userinfo;
import com.wsz.logistic.common.util.R;
import com.wsz.logistic.service.UserinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/vip")
public class VipController {
    @Autowired
    private UserinfoService userinfoService;

    @GetMapping("/uhome")
    public String uLogin() {
        return "/front/vip/uhome";
    }

    @GetMapping("/dhome")
    public String dLogin() {

        return "/front/vip/dhome";
    }

    @GetMapping("/logout")
    public String logout(HttpServletRequest request) {
        request.getSession().removeAttribute("loginInfo");
        return "front/index";
    }

    @GetMapping("/password")
    public String password() {
        return "front/userinfo-password";
    }

    @PostMapping("/password")
    @ResponseBody
    public R update(Userinfo userinfo) {
        userinfoService.saveOrUpdate(userinfo);
        return R.ok();
    }

}
